package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.entity.Drug;
import com.sky.enumeration.OperationType;
import com.sky.vo.DrugVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DrugMapper {
    /**
     * 获取用户的药品列表分页展示
     * @param userId 根据用户id
     * @return
     */
    @Select("select id, drug_name, picture from drug where user_id = #{userId}")
    List<Drug> listByUserId(Long userId);

    /**
     * 获取药品信息
     * @param id 药品id
     * @return
     */
    @Select("select * from drug where id = #{id};")
    Drug selectById(Long id);

    /**
     * 添加一个新的药品
     * @param drug
     */
    @AutoFill(OperationType.INSERT)
    void insert(Drug drug);

    /**
     * 删除药品
     * @param id 药品id
     */
    @Delete("delete from drug where id = #{id}")
    void deleteById(Long id);

    /**
     * 更新药品
     * @param drug
     */
    @AutoFill(OperationType.UPDATE)
    void update(Drug drug);

    /**
     * 获取到药品信息
     * @param id category的id
     * @return
     */
    @Select("select * from category_drug where category_id=#{id}")
    List<Drug> getListByCategoryId(Long id);

    /**
     * 根据药品ids批量获取到药品信息
     * @param drugIds
     * @return
     */
    List<Drug> getListByIds(List<Long> drugIds);
}
